home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / util / pack / xpk_Source.lha / xpk_Source / test / testXpkMasterPrefsSem.c < prev    next >
C/C++ Source or Header  |  1998-02-08  |  3KB  |  134 lines

  1. #define NAME        "testXpkMasterPrefsSem"
  2. #define DISTRIBUTION    "(Freeware) "
  3. #define REVISION    "6"
  4.  
  5. /* Programmheader
  6.  
  7.     Name:        testXpkMasterPrefsSem
  8.     Author:        SDI
  9.     Distribution:    Freeware
  10.     Description:    tests "« XpkMasterPrefs »" Semaphore work
  11.     Compileropts:    -
  12.     Linkeropts:    -
  13.  
  14.  1.0   25.12.96 : first Version
  15.  1.1   26.12.96 : xpkprefs.h changed nearly totally
  16.  1.2   27.12.96 : reduced length of Forbid()/Permit()
  17.  1.3   28.02.97 : semaphore style changed
  18.  1.4   01.03.97 : XpkMainPrefs changed a bit
  19.  1.5   24.03.97 : error fix
  20.  1.6   02.04.97 : changed the XpkTypeData structure
  21. */
  22.  
  23. #include <proto/exec.h>
  24. #include <proto/dos.h>
  25. #include <exec/memory.h>
  26. #include "SDI_defines.h"
  27. #include "PrintFlags.c"
  28. #include <xpk/xpkprefs.h>
  29.  
  30. /* This is a XpkMasterPrefs private structure !!!!! */
  31.  
  32. struct XpkTypeNode {
  33.   struct Node        xtn_Node;
  34.   ULONG            xtn_Size;
  35.   struct XpkTypePrefs    xtn_TypePrefs;
  36. };
  37.  
  38. void WriteXpkTypeData(struct XpkTypeData *xp)
  39. {
  40.   STRPTR a = 0;
  41.  
  42.   PutStr("xtd_Flags     : ");
  43.   {
  44.     ULONG i = xp->xtd_Flags;
  45.     PrintFlag(&i, XTD_NoPack,      "XTD_NoPack");
  46.     PrintFlag(&i, XTD_ReturnError, "XTD_ReturnError");
  47.     PrintEndFlag(i, xp->xtd_Flags);
  48.   }
  49.   a = (STRPTR) &xp->xtd_StdID;
  50.   VPrintf("xtd_StdID     : %lx", a);
  51.   VPrintf(" (%.4s)\n", &a);
  52.   VPrintf(
  53.   "xtd_ChunkSize : %ld\n"
  54.   "xtd_Mode      : %d\n"
  55.   "xtd_Version   : %d\n"
  56.   "xtd_Password  : %s\n", &xp->xtd_ChunkSize);
  57. }
  58.  
  59. void WriteXpkTypePrefs(struct XpkTypePrefs *xp)
  60. {
  61.   PutStr("xtp_Flags       : ");
  62.   {
  63.     ULONG i = xp->xtp_Flags;
  64.     PrintFlag(&i, XPKT_NamePattern, "XPKT_NamePattern");
  65.     PrintFlag(&i, XPKT_FilePattern, "XPKT_FilePattern");
  66.     PrintEndFlag(i, xp->xtp_Flags);
  67.   }
  68.   VPrintf(
  69.     "xtp_TypeName    : %s\n"
  70.     "xtp_NamePattern : %s\n"
  71.     "xtp_FilePattern : %s\n"
  72.     "xtp_PackerData  :\n", &xp->xtp_TypeName);
  73.   WriteXpkTypeData(xp->xtp_PackerData);
  74. }
  75.  
  76. void WriteXpkMainPrefs(struct XpkMainPrefs *xp)
  77. {
  78.   VPrintf("xmp_Version     : %ld\n", &xp->xmp_Version);
  79.   PutStr("xmp_Flags       : ");
  80.   {
  81.     ULONG i = xp->xmp_Flags;
  82.     PrintFlag(&i, XPKM_UseXFD, "XPKM_UseXFD");
  83.     PrintFlag(&i, XPKM_AutoPassword, "XPKM_AutoPassword");
  84.     PrintFlag(&i, XPKM_UseExternals, "XPKM_UseExternals");
  85.     PrintEndFlag(i, xp->xmp_Flags);
  86.   }
  87.   PutStr("xmp_DefaultType :\n");
  88.   WriteXpkTypeData(xp->xmp_DefaultType);
  89.   VPrintf("xmp_Timeout     : %d\n", &xp->xmp_Timeout);
  90. }
  91.  
  92. ULONG main(void)
  93. {
  94.   struct XpkPrefsSemaphore *sem;
  95.  
  96.   Forbid();
  97.   if((sem = (struct XpkPrefsSemaphore *) FindSemaphore(XPKPREFSSEMNAME)))
  98.     ObtainSemaphoreShared((struct SignalSemaphore *) sem);
  99.   Permit();
  100.  
  101.   if(sem)
  102.   {
  103.     VPrintf("xps_Version       : %ld\n", &sem->xps_Version);
  104.     {
  105.       STRPTR b;
  106.       b = (STRPTR) &sem->xps_PrefsType;
  107.       VPrintf("xps_PrefsType     : %lx", b);
  108.       VPrintf(" (%.4s)\n", &b);
  109.     }
  110.     VPrintf("xps_RecogSize     : %ld\n", &sem->xps_RecogSize);
  111.  
  112.     if(sem->xps_MainPrefs)
  113.     {
  114.       WriteXpkMainPrefs(sem->xps_MainPrefs);
  115.       PutStr("\n");
  116.     }
  117.  
  118.     if(sem->xps_PrefsType == XPREFSTYPE_STANDARD)
  119.     {
  120.       struct Node *n;
  121.       n = ((struct List *) sem->xps_PrefsData)->lh_Head;
  122.  
  123.       for(;n->ln_Succ && !CTRL_C; n = n->ln_Succ)
  124.       {
  125.         WriteXpkTypePrefs(&((struct XpkTypeNode *) n)->xtn_TypePrefs);
  126.         PutStr("\n");
  127.       }
  128.     }
  129.     ReleaseSemaphore((struct SignalSemaphore *) sem);
  130.   }
  131.   else
  132.     PutStr(XPKPREFSSEMNAME " Semaphore not found.\n");
  133. }
  134.